package org.dromara.common.core.config;


import okhttp3.OkHttpClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.net.http.HttpClient;
import java.time.Duration;

@Configuration
public class HttpClientConfig {



    @Bean
    public OkHttpClient okHttpClient() {
        return new OkHttpClient.Builder()
            .connectTimeout(Duration.ofSeconds(30))//连接超时
            .writeTimeout(Duration.ofSeconds(30))//写超时，也就是请求超时
            .readTimeout(Duration.ofSeconds(30))//读取超时
            .callTimeout(Duration.ofSeconds(30))//调用超时，也是整个请求过程的超时
            .build();
    }
}
